
var app = getApp();
var content = "";
var phone = "";
Page({
  data: {
    img: app.globalData.source + "Group.png",
  },
  content: function(e) {
    this.data.content = e.detail.value;
  },
  phone: function(e) {
    this.data.phone = e.detail.value;
  },
  /**
   * 提交反馈意见
   */
  feedbackSubmit: function(e) {
    content = this.data.content; //意见
    phone = this.data.phone; //手机号
    if (content == undefined) {
      wx.showToast({
        title: '请填写您宝贵的意见',
        icon: 'none',
        duration: 2000
      })
      return;
    }
    if (phone == undefined) {
      wx.showToast({
        title: '请填写手机号',
        icon:"none",
        duration: 1500
  
      })
      return;
    }

    if (phone.length!=11) {
      wx.showToast({
        title: '手机号码格式有误',
        icon: "none",
        duration: 1500
      })
      return;
    }

    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
    if (!myreg.test(phone)) {
      wx.showToast({
        title: '手机号码格式有误',
        icon: "none",
        duration: 1500
      })
      return ;
    }

    console.log("点击了提交反馈按钮，意见：" + content + ";电话：" + phone)
    var data = {
      adviseContent: content,
      mobile: phone,
      userId: app.globalData.userId
    }
    app.requestLoading(app.globalData.https + "feekbackResource/feekback",
      "post", data, "提交中...",
      function(res) {
        console.log(res)
        if (res.code == 0) {
          wx.showToast({
            title: '提交反馈成功',
            icon: 'none',
            duration: 5000
          })
        }
      }
    )

  }
})